package spe.common.plugins;

import java.net.URL;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * @author: Dao Anh Vu 
 * @date: May 29, 2012
 * */

public abstract class AbstractPlugin extends AbstractUIPlugin 
{
	protected URL iconUrl;
	
	public AbstractPlugin()
	{
		super();
	}
	
	protected void init()throws Exception
	{
		
	}
	
	@Override
	public void start(BundleContext context) throws Exception
	{
		super.start(context);
	}
	
	public ImageDescriptor getImageDescriptor(String relativePath)
	{
		try{
			//Bundle b = Platform.getBundle("spe");
			URL url = new URL(iconUrl, relativePath);
			//URL url = BundleUtility.find(b, relativePath);
			return ImageDescriptor.createFromURL(url);
		}//catch(MalformedURLException me)
		catch(Exception me)
		{
			return null;
		}
	}
}
